package com.example.tests;

import static org.testng.Assert.assertEquals;

import java.util.Collections;
import java.util.List;

import org.testng.annotations.Test;

public class GroupModificationTests extends TestBase{

	@Test
	public void modifySomeGroup() {
		app.getNavigationHelper().openMainPage();
	    app.getNavigationHelper().goToGroupsPage();
	    //save old state
	    
	    List<GroupData> oldlist = app.getGroupHelper().getGroups();
	    //action
		app.getGroupHelper().initGroupModification(0);
		GroupData group = new GroupData();
		group.name = "new name";
		app.getGroupHelper().fillGroupForm(group );
		app.getGroupHelper().submitGroupModification();
		app.getGroupHelper().returnToGroupPage();
		//save new state
	    List<GroupData> newlist = app.getGroupHelper().getGroups();
	    
	   // compare new state
	    oldlist.remove(0);
	    oldlist.add(group);
	    Collections.sort(oldlist);
	    assertEquals(newlist, oldlist);
	}
	
}
